package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.entity.OrdersAndDetail;
import com.sky.result.PageResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface OrderMapper {
    //插入订单
    void insert(Orders orders);

    //根据订单号查询订单
    Orders getByNumber(Map<String, Object> params);
    
    //根据订单号和用户ID查询订单
    Orders getByNumberAndUserId(Map<String, Object> params);

    //更新订单
    int update(Orders orders);

    //强制更新订单状态（解决动态SQL可能导致的更新失败问题）
    void forceUpdateOrder(Map<String, Object> params);

    //根据订单id查询订单
    @Select("select * from orders where id = #{id}")
    Orders getById(Long id);

    //分页查询订单
    Page<OrdersAndDetail> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
}
